/*
  ----------------------------------------------------------------------------------------------
  Test of SparkFun SerialLCD 16x2 Charcter Black/Green 
  ----------------------------------------------------------------------------------------------
  Physical Connections:
  -------------------------
  Arduino  | LCD
  -------- | --------------
  TX1 ------ SerLCD "RX"
  5V ------- SerLCD "VCC"
  GND ------ SerLCD "GND"

*/

/*----------------------------------------------------------------------------------------------*/
void setup() {
    
  Serial1.begin(9600);
  backlightSerLcd(70);
  clearSerLcd();
  Serial1.print("Muthanna 2012!!");
  delay(2000);
}
/*----------------------------------------------------------------------------------------------*/
void loop() { 

  clearSerLcd();
  
  Serial1.print("Hello World");
  line2SerLcd();
  Serial1.print(" Wowwwwww ");
  delay(200);
}
/*----------------------------------------------------------------------------------------------*/
void clearSerLcd(){
  Serial1.write(0xFE);                              //command flag
  Serial1.write(0x01);                              //clear command.
  delay(50);
}
/*----------------------------------------------------------------------------------------------*/
void backlightSerLcd(int thePercentage){            //turns on the backlight
  Serial1.write(0x7C);                              //command flag for backlight stuff
  int theValue = map(thePercentage, 0,100,128,157); // maps percentage to what SerLCD wants to see
  Serial1.write(theValue);                          //light level.
  delay(50);
}
/*----------------------------------------------------------------------------------------------*/
void line2SerLcd(){
  Serial1.write(0xFE);                              //command flag
  Serial1.write(0xC0);                              //move cursor to first location in 2nd line.
  delay(50);
}
/*----------------------------------------------------------------------------------------------*/
